package cn.cdeden.knowledge.controller.team;

import cn.cdeden.common.core.domain.R;
import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.knowledge.domain.dto.TeamRelevanceTypeDto;
import cn.cdeden.knowledge.domain.dto.TeamRelevanceTypeQueryParam;
import cn.cdeden.knowledge.service.TeamRelevanceTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
* @author Chen
* @date 2024-04-21
**/
@RestController
@RequiredArgsConstructor
//@Api(tags = "团队分类关联表管理")
@RequestMapping("/api/teamRelevanceType")
public class TeamRelevanceTypeController {

    private final TeamRelevanceTypeService teamRelevanceTypeService;

    @GetMapping
//    @Log("查询团队分类关联表")
//    @ApiOperation("查询团队分类关联表")
    public R<TableDataInfo<TeamRelevanceTypeDto>> query(TeamRelevanceTypeQueryParam query, Pageable pageable){
        TableDataInfo<TeamRelevanceTypeDto> info = teamRelevanceTypeService.queryAll(query,pageable);
        return R.ok(info);
    }

    @PostMapping
//    @Log("新增团队分类关联表")
//    @ApiOperation("新增团队分类关联表")
    public R create(@Validated @RequestBody TeamRelevanceTypeDto resources){
        return R.ok(teamRelevanceTypeService.insert(resources));
    }

//    @PutMapping
////    @Log("修改团队分类关联表")
////    @ApiOperation("修改团队分类关联表")
//    public R update(@Validated @RequestBody TeamRelevanceTypeDto resources){
//        return R.ok()(teamRelevanceTypeService.updateById(resources));
//    }

    @DeleteMapping
//    @Log("删除团队分类关联表")
//    @ApiOperation("删除团队分类关联表")
    public R delete(@RequestBody TeamRelevanceTypeDto resources) {
        return R.ok(teamRelevanceTypeService.deleteRelevanceType(resources));
    }

    /*
//    @Log("导出团队分类关联表")
//    @ApiOperation("导出团队分类关联表")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('teamRelevanceType:list')")
    public void download(HttpServletResponse response, TeamRelevanceTypeQueryParam query) throws IOException {
        teamRelevanceTypeService.download(teamRelevanceTypeService.queryAll(query), response);
    }*/

}
